// Slider.cs
//

using System;
using System.Collections.Generic;
using jQueryApi;
using System.Runtime.CompilerServices;
using System.Html;

namespace TuringMachine
{
   [GlobalMethods]
   [IgnoreNamespace]
   [Imported]
   public static class Sliders
   {
      [ScriptAlias("TransformSliders")]
      public static void Transform()
      {
      }
   }

   [GlobalMethods]
   [IgnoreNamespace]
   [Imported]
   public class SliderElement : Element
   {
      public EventHandler onchange;
   }

   public class Slider : Span
   {
      jQueryObject m_slider;
      public event EventHandler OnChange;
      public Slider(jQueryObject parent, string id, int min, int max, int step) :
         base(parent, id)
      {
         pObject.Append("<input id='input_" + id + "' type='range' step='" + step + "' max='" + max + "' min='" + min + "'></input>");
         m_slider = pObject.Children();
         SliderElement el = (SliderElement)m_slider[0];
         el.onchange = delegate
         {
            if (OnChange != null)
               OnChange(this, null);
         };

         Sliders.Transform();
      }

      public int pValue
      {
         get
         {
            return int.Parse(m_slider.GetAttribute("value"));
         }
         set
         {
            m_slider.Attribute("value", value.ToString());
         }
      }
   }
}
